package com.behome.web.controller.equipment;

import com.behome.common.annotation.Log;
import com.behome.common.core.controller.BaseController;
import com.behome.common.core.domain.AjaxResult;
import com.behome.system.domain.TTerminalInfo;
import com.behome.common.core.page.TableDataInfo;
import com.behome.common.enums.BusinessType;
import com.behome.system.service.ITerminalInfoService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 区域信息
 *
 * @author behome
 */
@RestController
@RequestMapping("/equipment/terminal")
public class TerminalController extends BaseController {

    @Resource
    private ITerminalInfoService iTerminalInfoService;

    /**
     * 获取区域列表
     */
    @PreAuthorize("@ss.hasPermi('equipment:terminal:list')")
    @GetMapping("/list")
    public TableDataInfo list(TTerminalInfo tTerminalInfo) {
        startPage();
        List<TTerminalInfo> list = iTerminalInfoService.selectTeminalInfoList(tTerminalInfo);
        return getDataTable(list);
    }

    /**
     * 添加设备
     */
    @PreAuthorize("@ss.hasPermi('equipment:terminal:add')")
    @Log(title = "添加设备", businessType = BusinessType.INSERT)
    @PutMapping("/add")
    public AjaxResult add(@Validated @RequestBody TTerminalInfo tTerminalInfo)
    {
        return toAjax(iTerminalInfoService.insertUser(tTerminalInfo));
    }

    /**
     * 修改设备
     */
    @PreAuthorize("@ss.hasPermi('equipment:terminal:edit')")
    @Log(title = "修改设备", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@Validated @RequestBody TTerminalInfo tTerminalInfo)
    {
        return toAjax(iTerminalInfoService.updateTerminal(tTerminalInfo));
    }
}
